package com.imooc.mall.model.config;

import com.imooc.mall.model.filter.AdminFilter;
import com.imooc.mall.model.filter.UserFilter;
import com.imooc.mall.model.pojo.User;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

@Configuration    //声明配置文件，如。xml文件
public class UserFilterConfig {

    @Bean
    public UserFilter userFilter(){
        return new UserFilter();
    }

    @Bean("userFilterConf")
    public FilterRegistrationBean adminFilterConfig(){
        FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<>();
        bean.setFilter(userFilter());
        bean.addUrlPatterns("/cart/*");
        bean.addUrlPatterns("/order/*");
        bean.setName("userFilterConfig");
        return bean;
    }


}
